Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@babel/plugin-transform-react-display-name
Advanced tools
Add displayName to React.createClass calls
The @babel/plugin-transform-react-display-name npm package is a Babel plugin that adds the displayName property to React components for use in debugging messages and dev tools. It helps to identify components in the React DevTools by providing a readable name, which is particularly useful for anonymous components.
Automatic displayName assignment for React components
This feature automatically assigns a displayName to React components based on their name. This is useful for debugging purposes, as it allows you to see the component's name in the React DevTools.
class MyComponent extends React.Component {}
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
displayName assignment for functional components
Similar to class components, this feature assigns a displayName to functional components, making them easier to identify in the React DevTools.
const MyComponent = () => <div />;
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
displayName assignment for components created with React.createClass
For components created using React.createClass, this plugin also adds a displayName property, which is useful for projects that have not yet migrated to ES6 classes or functional components.
const MyComponent = React.createClass({
render: function() { return <div />; }
});
// Transformed code with displayName:
// MyComponent.displayName = 'MyComponent';
This package is similar to @babel/plugin-transform-react-display-name as it also adds a displayName to React components. However, it is a standalone Babel plugin that might not be as actively maintained or integrated into the Babel ecosystem as the official Babel plugin.
This package provides a utility function to help manually assign a displayName to a React component. It is not a Babel plugin and requires manual usage within the code, unlike the automatic transformation provided by @babel/plugin-transform-react-display-name.
Add displayName to React.createClass calls
See our website @babel/plugin-transform-react-display-name for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-react-display-name
or using yarn:
yarn add @babel/plugin-transform-react-display-name --dev
v7.25.9 (2024-10-22)
babel-parser
, babel-template
, babel-types
syntacticPlaceholders
mode (@liuxingbaoyu)babel-helper-compilation-targets
, babel-preset-env
ClassAccessorProperty
to prevent the no-undef
rule (@victorenator)babel-parser
, babel-types
VISITOR_KEYS
etc. faster to access (@liuxingbaoyu)FAQs
Add displayName to React.createClass calls
We found that @babel/plugin-transform-react-display-name demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.